
var config = $.extend(true, {}, listApp, {
	data : {
		service : sendtoService,
		// searchVm : {
        //     ip : '',
        //     port:'',
		// 	nettype:''
		// },
		addVm:{
			charset:'GBK'
		},
		options1:[{
			label:'SOCKET',
			value:'SOCKET'
		},
			{
				label:'HTTP',
				value:'HTTP'
			},

		],
		options2:[{
			label:'数据',
			value:0
		},
			{
				label:'警报',
				value:1
			},

		],
		options3:[{
			label:'GBK',
			value:'GBK'
		},
			{
				label:'Unicode',
				value:'Unicode'
			},
			{
				label:'UTF-8',
				value:'UTF-8'
			},

		],
		editVm: {
			editFormRules:{
				formRules:{
					ip : [ {required : true,message : '请输入远端服务器IP',trigger : 'change'},
						{
							validator:function(rule, value, callback){
								var regPos = /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/;
								if(regPos.test(value)){
									callback();
								}else{
									callback(new Error('请输入正确的IP地址'));
								}
							},
							trigger:'change'
						} ],
					port : [ {required : true,message : '请输入端口',trigger : 'change'}],
					mode : [ {required : true,message : '请选择数据格式',trigger : 'change'} ],
					dataType : [ {required : true,message : '请选择数据类型',trigger : 'change'} ],
                    times : [ {required : true,message : '请输入输出间隔',trigger : 'change'},
						{
							validator:function(rule, value, callback){
								var regPos = /^[0-9]*$/;
								if(regPos.test(value)){
									callback();
								}else{
									callback(new Error('间隔必须为数值'));
								}
							},
							trigger:'blur'
						}
					]
                }
		    }

		}
	},
	methods:{
		formatterType:function(row,column){
			return row.dataType===0 ? "数据" : (row.dataType===1 ?"警报":"未知");
		},
		formatterStatus:function(row){
			return row.status===1 ? "发送正常":"连接超时"
	    },
		filterClass:function(row){
			if(row.columnIndex === 5){
				return row.row.status===1 ?"green":"red";
			}
		},
		refresh:function () {
			this.search();
		},
		restart:function () {
			var _this = this;
			this.$confirm('此操作将重启服务, 是否继续?', '提示', {
				confirmButtonText : '确定',
				cancelButtonText : '取消',
				type : 'warning'
			}).then(function() {
				_this.service.restartService('/restart',null,{
					success : function(ret){
						console.log(ret);
					},
					fail:function (res) {

					}
				})
			});


		}
	}
});
var app = new Vue(config);
